home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
creaport.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-10-30
|
2KB
|
71 lines
/***********************************************************************
*
* Exec Support Functions -- Ports and Messages
*
***********************************************************************/
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/memory.h"
#include "exec/interrupts.h"
#include "exec/ports.h"
#include "exec/libraries.h"
#include "exec/tasks.h"
#include "exec/execbase.h"
extern APTR AllocMem();
extern UBYTE AllocSignal();
extern struct Task *FindTask();
struct MsgPort *CreatePort (name, pri)
char *name;
BYTE pri;
{
UBYTE sigBit;
struct MsgPort *port;
if ((sigBit = AllocSignal (-1)) == -1)
return ((struct MsgPort *) 0);
port = AllocMem ((ULONG) sizeof (*port), MEMF_CLEAR | MEMF_PUBLIC);
if (port == 0) {
FreeSignal (sigBit);
return ((struct MsgPort *) (0));
}
port -> mp_Node.ln_Name = name;
port -> mp_Node.ln_Pri = pri;
port -> mp_Node.ln_Type = NT_MSGPORT;
port -> mp_Flags = PA_SIGNAL;
port -> mp_SigBit = sigBit;
port -> mp_SigTask = FindTask (0);
if (name != 0)
AddPort (port);
else
NewList (&(port -> mp_MsgList));
return (port);
}
DeletePort(port)
struct MsgPort *port;
{
if ((port -> mp_Node.ln_Name) != 0)
RemPort (port);
port -> mp_Node.ln_Type = 0xff;
port -> mp_MsgList.lh_Head = (struct Node *) - 1;
FreeSignal (port -> mp_SigBit);
FreeMem (port, (ULONG) sizeof (*port));
}